﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;


namespace eCitizen.eAlerts.BatchFramework
{
    public class BatchErrorLogger
    {
        Logger _batchLogger;
        BatchBehavior _currentBatchService;

        public BatchErrorLogger(BatchBehavior currentBatchService)
        {
            _batchLogger = LogManager.GetCurrentClassLogger();
            _currentBatchService = currentBatchService;
        }

        public void LogInfo(string errorMessage)
        {
            _batchLogger.Log(LogLevel.Info, errorMessage);
        }

        public void LogException(Exception ex)
        {
            string errorFormat = "Error Message : {0}, Source : {1} Stack Trace : {2}";
            string errorMessage = String.Format(errorFormat, ex.Message, ex.Source, ex.StackTrace);
            _batchLogger.Log(LogLevel.Error, errorMessage);
            _batchLogger.ErrorException(_currentBatchService.ToString(), ex);
        }
    }
}
